public class ThreadDemo4 {
    public static void main(String[] args) {
        singleInstance1 i = singleInstance1.getInstance1();
        singleInstance1 j = singleInstance1.getInstance1();
        System.out.println(i.equals(j));
    }
}

class singleInstance1 {
    private static singleInstance1 instance1 = new singleInstance1();// 静态成员变量类加载时直接创建
    private singleInstance1(){};//防止其它类用构造方法再次创建其它实例

    public static singleInstance1 getInstance1() {
        return instance1;
    }
}

